//
//  MineViewController.m
//  ZYShang
//
//  Created by wangguangming on 15/8/3.
//  Copyright © 2015年 Amber. All rights reserved.
//

#import "MineViewController.h"
#import "MineViewCell.h"
#import "Loadsingle.h"
#import "UserModel.h"
#import "CPWordViewController.h"
@interface MineViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *mainTable;
@end

@implementation MineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setBack];
    self.title=@"个人资料";
    self.mainTable=[[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    self.mainTable.delegate=self;
    self.mainTable.dataSource=self;
    [self.view addSubview:self.mainTable];
        // NSLog(@"%@",[Loadsingle single].userArray);
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 11;
}

    // Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
    // Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UserModel *user=[Loadsingle single].userArray[0];
   
    NSArray *array=@[@"姓名",@"工号",@"值班",@"性别",@"电话",@"部门",@"员工类型",@"系统权限",@"所在仓库"];
    NSString *a;
    if (user.checked.intValue!=0)
        {
        a=@"值班";
        }
    else
        {
        a=@"下班";
        }
    NSString *b=[self setrole:user.role.intValue];
    NSString *c=[self settype:user.type.integerValue];
    NSString *d;
    if ([user.gender isEqualToString:@"m"])
        {
        d=@"女";
        }
    else
        {
        d=@"男";
        }
    NSArray *itemArray=@[user.name,user.account,a,d,user.tel,user.dptName,c,b,user.mktName];
    if (indexPath.row>0&&indexPath.row<10)
        {
        MineViewCell *cell=[[MineViewCell alloc] init];
        cell.nameLaber.text=array[indexPath.row-1];
        cell.textfield.text=itemArray[indexPath.row-1];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        return cell;
        }
    if (indexPath.row==10)
        {
        UITableViewCell *cell=[[UITableViewCell alloc] init];
        cell.textLabel.textAlignment=NSTextAlignmentCenter;
        cell.textLabel.text=@"修改密码";
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        return cell;
      }
    else
        {
    UITableViewCell *cell=[[UITableViewCell alloc] init];
    cell.textLabel.text= [NSString stringWithFormat:@"%d",indexPath.row];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
     return cell;
        }
    
}
-(NSString *)settype:(int)intvalu
{
    if (intvalu==1)
        {
        return @"全职";
        }
    if (intvalu==2)
        {
        return @"兼职";
        }
    if (intvalu==3)
        {
        return @"实习生";
        }
    if (intvalu==4)
        {
        return @"试用期";
        }
       else
        {
        return @"";
        }

    }
-(NSString *)setrole:(int)intvalu
{
    if (intvalu==1)
        {
        return @"超级管理员";
        }
    if (intvalu==2)
        {
        return @"配送管理员";
        }
    if (intvalu==3)
        {
        return @"送货人员";
        }
    if (intvalu==4)
        {
        return @" 配货人员";
        }
    if (intvalu==5)
        {
        return @"配送人员";
        }
    else
        {
        return @"";
        }
 
}
-(void)tableView:(nonnull UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
    if (indexPath.row==10)
        {
        CPWordViewController *cpwordViewController=[[CPWordViewController alloc] init];
        [self.navigationController pushViewController:cpwordViewController animated:YES];
        }
    else
        {
       
        }
}
/**
 public static class Role {
 public static final Integer ADMIN = 1; // 超级管理员，具有所有权限
 public static final Integer MANAGER = 2; // 配送管理员
 public static final Integer DELIVERYMAN = 3; // 送货人员
 public static final Integer PICKINGMAN = 4; // 配货人员
 }
 */

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
